<template>
    <div class="screen" :style="{ backgroundImage: `linear-gradient(180deg, rgba(255,245,225,.7), rgba(255,245,225,.9)), url(${bgUrl})` }">
        <header class="topbar">
            <button class="icon-btn" @click="goBack" aria-label="back">
                <svg viewBox="0 0 24 24" width="24" height="24">
                    <path fill="currentColor" d="M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
                </svg>
            </button>
            <div class="title">更多设置</div>
        </header>

        <!-- 可滚动内容区域 -->
        <div class="scrollable-content">
            <div class="settings-card">
                <button class="setting-item logout-btn" @click="handleLogout">
                    <div class="setting-icon logout-icon">
                        <svg viewBox="0 0 24 24" width="20" height="20" fill="white">
                            <path d="M17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.59L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z"/>
                        </svg>
                    </div>
                    <span class="label">退出登录</span>
                    <span class="arrow">></span>
                </button>
            </div>
        </div>
    </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { bgUrl } from '@/config/background.js'
import { clearToken } from '@/utils/auth.js'

const router = useRouter()

function goBack() {
    router.back()
}

function handleLogout() {
    // 清除token
    clearToken()
    // 跳转到登录页面
    router.replace('/login')
}
</script>

<style scoped>
.screen {
    position: fixed;
    inset: 0;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    position: relative;
    z-index: 1;
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}

.icon-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #0f172a;
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.title {
    font-size: 18px;
    font-weight: 600;
    color: #0f172a;
}

/* 可滚动内容区域 */
.scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.settings-card {
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(6px);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    overflow: hidden;
    max-width: 980px;
    margin: 0 auto;
}

.setting-item { 
    display: grid; 
    grid-template-columns: 40px 1fr auto; 
    align-items: center; 
    gap: 12px; 
    padding: 14px 16px; 
    background: transparent; 
    border: none; 
    border-bottom: 1px solid rgba(0,0,0,.06); 
    cursor: pointer; 
    color: #111827; 
    text-align: left;
    width: 100%;
    transition: background 0.2s;
}

.setting-item:last-child { 
    border-bottom: none; 
}

.setting-item:hover {
    background: rgba(0,0,0,.02);
}

.setting-item.logout-btn .label {
    color: #ef4444;
    font-weight: 500;
}

.setting-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.logout-icon {
    background: #ef4444;
}

.label { 
    font-size: 16px; 
    font-weight: 500;
}

.arrow { 
    color: #9ca3af; 
    font-weight: 700;
    font-size: 18px;
}
</style>

